package com.beerandjesus.sportofkings.handicapper.model;

import static com.beerandjesus.sportofkings.handicapper.factory.ResultsTableFactory.*;

/**
 * Date: Jul 14, 2012
 * Time: 10:21:58 AM
 */
public class NonMaidenHorseAnalysisResultImpl extends HorseAnalysisResultImpl
        implements NonMaidenHorseAnalysisResult {

    private String quirinSpeedPoints;
    private Boolean upCloseWhenStalking;
    private Boolean winsOffPace;
    private int recentWins;
    private int recentPlaces;
    private int recentShows;


    public String getQuirinSpeedPoints() {
        return quirinSpeedPoints;
    }

    public void setQuirinSpeedPoints(String quirinSpeedPoints) {
        this.quirinSpeedPoints = quirinSpeedPoints;
    }

    public Boolean getUpCloseWhenStalking() {
        return upCloseWhenStalking;
    }

    public void setUpCloseWhenStalking(Boolean upCloseWhenStalking) {
        this.upCloseWhenStalking = upCloseWhenStalking;
    }

    public Boolean getWinsOffPace() {
        return winsOffPace;
    }

    public void setWinsOffPace(Boolean winsOffPace) {
        this.winsOffPace = winsOffPace;
    }

    public int getRecentWins() {
        return recentWins;
    }

    public void setRecentWins(int recentWins) {
        this.recentWins = recentWins;
    }

    public int getRecentPlaces() {
        return recentPlaces;
    }

    public void setRecentPlaces(int recentPlaces) {
        this.recentPlaces = recentPlaces;
    }

    public int getRecentShows() {
        return recentShows;
    }

    public void setRecentShows(int recentShows) {
        this.recentShows = recentShows;
    }

    public void addToTable(ResultsTable table) {

        table.putValue(getPostPosition(), getResultType(), Q_PTS, getQuirinSpeedPoints());
        table.putValue(getPostPosition(), getResultType(), UP_CLOSE,
                parseBooleanToString(getUpCloseWhenStalking(), "", "yes", "no"));
        table.putValue(getPostPosition(), getResultType(), W_OFF_PACE,
                parseBooleanToString(getWinsOffPace(), "", "yes", "no"));
        table.putValue(getPostPosition(), getResultType(), SPEED, getParSpeedCount() + "par " +
                getSpeedFigure());
        table.putValue(getPostPosition(), getResultType(), WPS,
                getRecentWins() + " " + getRecentPlaces() + " " + getRecentShows());
        table.putValue(getPostPosition(), getResultType(), WORKS, concatenateFastWorkouts());
        table.putValue(getPostPosition(), getResultType(), NAME, getName());
        String ml = "";
        if (getMorningLine() != null) {
            ml = getMorningLine().toImproperFractionString();
        }
        table.putValue(getPostPosition(), getResultType(), MORNING_LINE, ml);
        table.putProfiles(getPostPosition(), getResultType(), getProfiles());
    }

    private String parseBooleanToString(Boolean aBoolean, String aNull, String aTrue, String aFalse) {
        return (aBoolean == null ? aNull : (aBoolean ? aTrue : aFalse));
    }
}
